package com.syni.mdd.yhd.common.all.controller.api.business;

import com.syni.mdd.sjb.common.component.utils.common.utils.RpcResponseVo;
import com.syni.mdd.yhd.common.all.constants.ResultCode;
import com.syni.mdd.yhd.common.all.constants.ResultMsg;
import com.syni.mdd.yhd.common.all.entity.BmsBusinessType;
import com.syni.mdd.yhd.common.all.service.BmsBusinessTypeService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

/**
 * @className BusinessInfoRestApi
 * @description TOO
 * @Author cfx
 * @DATE 2020/4/6 22:14
 * @VERSION 1.0
 **/
@RestController
@RequestMapping("/apiBusinessType")
@Log4j2
public class BusinessTypeRestApi{


    @Autowired
    BmsBusinessTypeService bmsBusinesseTypeService;

    @GetMapping("/getBusinessTypeById")
    public RpcResponseVo getBusinessTypeById(@RequestParam("typeId") Integer typeId) {
        Optional<BmsBusinessType> bmsBusinessType = bmsBusinesseTypeService.getBaseDao().findById(typeId);
        if(bmsBusinessType.isPresent()){
            return RpcResponseVo.success(bmsBusinessType.get(),ResultMsg.MSG_GET_SUCCESS);
        }
        return RpcResponseVo.result(ResultCode.CODE_ERROR_05,ResultMsg.CODE_ERROR_05);
    }
}
